/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package operator.server;

import java.util.Scanner;

/**
 *
 * @author mire
 */
public class OperatorServerMain {

    public static void main(String[] args) {
        OperatorServer operatorServer = null;

        if (OperatorServer.existsConfugration()) {
            operatorServer = new OperatorServer();
        } else {
            Scanner in = new Scanner(System.in);
            System.out.println("Unesite ime operatera:");
            String operatorName = in.nextLine();

            System.out.println("Unesite prefixe operatera sa razmacima:");
            String prefix = in.nextLine();
            String[] prefixes = prefix.split(" ");

            System.out.println("Unesite adresu centralnog servera:");
            String centralAddress = in.nextLine();

            System.out.println("Unesite port centralnog servera");
            int globalCentralPort = in.nextInt();
            in.nextLine();

            String operatorAddress = null;
            System.out.println("Da je ovo prvi operatorski server?");
            String answer = in.nextLine();
            if (answer.contains("ne")) {
                System.out.println("Unesite adresu drugog operatorskog servera:");
                operatorAddress = in.nextLine();
            }

            System.out.println("Unesite port operatorskog servera");
            int operatorPort = in.nextInt();

            System.out.println("Unesite port za klijente");
            int clientPort = in.nextInt();

            System.out.println("Unesite port za komunikaciju sa centralnim serverom");
            int centralPort = in.nextInt();

            System.out.println("Unesite sekunde vreme provere");
            int aliveTimeout = in.nextInt();

            System.out.println("Unesite sekunde vremena chekanja");
            int waitTimeout = in.nextInt();

            System.out.println("Unesite maximalan broj poslova");
            int threadNo = in.nextInt();

            operatorServer = new OperatorServer(operatorName, prefixes, centralAddress, globalCentralPort, operatorAddress, operatorPort, clientPort, aliveTimeout, waitTimeout, threadNo, centralPort);

        }

        (new Thread(operatorServer)).start();

    }
}
